//
//  ShoppingTableViewCell.m
//  UGoods
//
//  Created by dllo on 16/1/26.
//  Copyright © 2016年 蓝鸥科技.李贺. All rights reserved.
//

#import "ShoppingTableViewCell.h"
#import "FindModel.h"
#import "BaseView.h"
#import "BaseLabel.h"
#import <UIImageView+WebCache.h>
#import "ConstantsDefine.h"
@interface ShoppingTableViewCell ()

@property (nonatomic, retain) UIImageView *goodsImageView;
@property (nonatomic, retain) BaseLabel *goodsNameLabel;
@property (nonatomic, retain) BaseLabel *priceLabel;


@end

@implementation ShoppingTableViewCell
- (void)dealloc
{
    [_goodsImageView release];
    [_goodsNameLabel release];
    [_priceLabel release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.goodsImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_goodsImageView];
        [_goodsNameLabel release];
        
        self.goodsNameLabel = [[BaseLabel alloc] init];
        //        _goodsNameLabel.textAlignment = NSTextAlignmentCenter;
        //        _goodsNameLabel.backgroundColor = [UIColor redColor];
        _goodsNameLabel.numberOfLines = 2;
        _goodsNameLabel.textAlignment = NSTextAlignmentLeft;
        _goodsNameLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_goodsNameLabel];
        [_goodsNameLabel release];
        
        self.priceLabel = [[BaseLabel alloc] init];
        //        _priceLabel.backgroundColor = [UIColor yellowColor];
        _priceLabel.textAlignment = NSTextAlignmentLeft;
        _priceLabel.font = [UIFont systemFontOfSize:14];
        _priceLabel.textColor = [UIColor redColor];
        [self.contentView addSubview:_priceLabel];
        [_priceLabel release];

    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    _goodsImageView.frame = CGRectMake(10 * WIDTH, 10 * HEIGHT, 80 * WIDTH, 80 * HEIGHT);
    _goodsNameLabel.frame = CGRectMake(100 * WIDTH, 10 * HEIGHT, self.contentView.frame.size.width - 110 * WIDTH, 20 * HEIGHT);
    _priceLabel.frame = CGRectMake(100 * WIDTH, 50 * HEIGHT, 200 * WIDTH, 20 * HEIGHT);
}

- (void)setModel:(FindModel *)model {
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    [_goodsImageView sd_setImageWithURL:[NSURL URLWithString:model.app_show_logo] placeholderImage:[UIImage imageNamed:@"place2"]];
    _goodsNameLabel.text = model.goods_name;
    _priceLabel.text = [NSString stringWithFormat:@"¥ %@", model.shop_price];
}

@end
